<template>
  <UView name="爬虫站点" >
    <UViewSearch v-model="searchModel">
      <URow col="search">
        <UInputItem field="name" label="平台" :allowClear="true"/>
        <UButton func="query" url="/crawler/sites/view">搜索</UButton>
        <UButton func="reset">重置</UButton>
<!--        <UButton func="add" url="/crawler/sites/add" v-auth="'crawler:sites:add'">新增</UButton>-->
<!--        <UButton func="ajax" url="/crawler/sites/open">打开浏览器</UButton>-->
      </URow>
    </UViewSearch>
    <UViewModal title="爬虫站点管理" :span="[7, 14]" v-model="editModel" :rules="rules">
      <template #default="{model}">
        <UInputItem field="name" label="站点名称" />
        <UInputItem field="domain" label="域名" />
      </template>
      <template #footer>
        <UButton func="cancel">取消</UButton>
        <UButton func="submit" url="/crawler/sites/saveOrUpdate">提交</UButton>
        <UButton func="reset">重置</UButton>
      </template>
    </UViewModal>
    <UViewTable :columns="columns" :scroll="{x: 1200}">
      <template #action="{record}">
        <UTag func="edit" :data="record" url="/crawler/sites/edit" v-auth="'crawler:sites:edit'">修改</UTag>
        <UTag func="ajax" :data="record" url="/crawler/sites/start">开始采集</UTag>
        <UTag func="del" :data="record" url="/crawler/sites/del" v-auth="'crawler:sites:del'">删除</UTag>
      </template>
    </UViewTable>
  </UView>
</template>
<!-- 爬虫站点功能 -->
<script>
import {ref, reactive} from "vue";
export default {
  name: "Sites",
  setup() {
    let types = ref([
      {label: '视频带货', value: 'video'},
      {label: '直播带货', value: 'live'},
    ])

    let columns = ref([
      {field: "name", title: "平台"},
      {field: "type", title: "类型", options: types},
      {field: "domain", title: "域名"},
      {field: "createTime", title: "创建时间"},
      {field: 'action', title: '操作', type: 'action', fixed: 'right', width: 280},
    ]);

    let rules = reactive({})

    let editModel = ref({});
    let searchModel = ref({});
    return {columns, rules, editModel, searchModel}
  },
}
</script>
<style scoped> </style>
